package com.cn.serverline.lineicp.workshopPlan.controller;

import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cn.serverline.lineicp.workshopPlan.entity.AuxiliaryMaterials;
import com.cn.serverline.lineicp.workshopPlan.entity.SparePartsType;
import com.cn.serverline.lineicp.workshopPlan.entity.request.AuxiliaryMaterialsRequest;
import com.cn.serverline.lineicp.workshopPlan.entity.request.SparePartsRequest;
import com.cn.serverline.lineicp.workshopPlan.service.AuxiliaryMaterialsService;
import com.cn.serverline.lineicp.workshopPlan.service.SparePartsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 零组件类型控制层
 *
 * @author 田江余
 * @date 2024年7月29日14:31:22
 */
@Api(tags = "零组件类型")
@RestController
@ApiResource(name = "零组件类型")
public class SparePartsTypeController {

    @Resource(name = "sparePartsServiceImpl")
    private SparePartsService sparePartsService    ;

    /**
     * 添加
     *
     * @author 田江余
     * @date 2024年7月29日
     */
    @ApiOperation(value = "添加零组件类型")
    @PostResource(name = "添加", path = "/sparePartsType/add")
    public ResponseData<?> add(@RequestBody @Validated SparePartsRequest sparePartsRequest) {
        return new SuccessResponseData<>(sparePartsService.add(sparePartsRequest));
    }

    /**
     * 删除
     *
     * @author 田江余
     * @date 2024年7月29日
     */
    @ApiOperation(value = "删除零组件类型")
    @PostResource(name = "删除", path = "/sparePartsType/delete")
    public ResponseData<?> delete(@RequestBody @Validated(SparePartsRequest.delete.class) SparePartsRequest sparePartsRequest) {
        sparePartsService.del(sparePartsRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 编辑
     *
     * @author 田江余
     * @date 2024年7月29日
     */
    @ApiOperation(value = "编辑零组件类型")
    @PostResource(name = "编辑", path = "/sparePartsType/edit")
    public ResponseData<?> edit(@RequestBody @Validated(SparePartsRequest.edit.class) SparePartsRequest sparePartsRequest) {
        sparePartsService.edit(sparePartsRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 获取列表
     *
     * @author 田江余
     * @date 2024年7月29日
     */
    @ApiOperation(value = "查询零组件类型")
    @GetResource(name = "获取列表", path = "/sparePartsType/list")
    public ResponseData<Page<SparePartsType>> list(SparePartsRequest sparePartsRequest) {
        return new SuccessResponseData<>(sparePartsService.findList(sparePartsRequest));
    }
}
